//
//  ChannelModel.m
//  QWwyNews
//
//  Created by Amisear on 15/10/9.
//  Copyright © 2015年 Amisear. All rights reserved.
//

#import "ChannelModel.h"
#import "NSObject+Extension.h"

@implementation ChannelModel

+ (NSArray *)ChannelList {
    
    //加载json二进制
    NSString *path = [[NSBundle mainBundle]pathForResource:@"topic_news.json" ofType:nil];
    NSData *data = [NSData dataWithContentsOfFile:path];
    //2. 反序列化
    
    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];
    //从字典中获得模型
    NSArray *array = dict[dict.keyEnumerator.nextObject];
    //遍历数组,字典转模型
    NSMutableArray *arrayM = [NSMutableArray arrayWithCapacity:array.count];
    
    for (NSDictionary *dic in array) {
        [arrayM addObject:[self ObjectWithDict:dic]];
    }
    return arrayM.copy;
}

@end
